import {reqGoodsInfo} from '@/api/index'
const state = {
  goodInfo:{},// 产品信息
}
const mutations = {
  GOODINFO(state,goodInfo){
    state.goodInfo = goodInfo
  }
}
const actions = {
  // 页面dispatch 触发action
  async getGoodInfo({commit},skuId){
    let res = await reqGoodsInfo(skuId)
    if(res.code == 200){
      commit('GOODINFO',res.data)
    }
  }
}
const getters = {
  categoryView(state){
    return state.goodInfo.categoryView || {}
  },
  skuInfo(state){
    return state.goodInfo.skuInfo || {}
  },
  spuSaleAttrList(state){
    return state.goodInfo.spuSaleAttrList || {}
  }
};
export default {
  state,
  mutations,
  actions,
  getters
}